package com.magnusart.scrumppm.model;

import java.util.ArrayList;
import java.util.List;

import com.magnusart.scrumppm.model.Story.Units;

public class StoryBuilder implements Builder
{
	private int id;
	private String title;
	private String description;
	private String deliverable;
	private int priority;
	private Units estimatedUnits;
	private boolean isDone;
	private boolean skip;
	private List<Task> children;

	public StoryBuilder( Story story ) {
		this.id = story.getID();
		this.title = story.getTitle();
		this.deliverable = story.getDeliverable();
		this.description = story.getDescription();
		this.priority = story.getPriority();
		this.estimatedUnits = story.getEstimatedUnits();
		this.isDone = story.isDone();
		this.skip = story.skip();
		this.children = story.getChildren();
	}
	public StoryBuilder() {
		priority = 0;
		estimatedUnits = Units.UNSPECIFIED;
		isDone = false;
		skip = false;
	}
	
	int getID() {
		return id;
	}
	public void setID( int id ) {
		this.id = id;
	}
	String getTitle() {
		return title;
	}
	public void setTitle( String title ) {
		this.title = title;
	}
	String getDescription() {
		return description;
	}
	public void setDescription( String description ) {
		this.description = description;
	}
	String getDeliverable() {
		return deliverable;
	}
	public void setDeliverable( String deliverable ) {
		this.deliverable = deliverable;
	}
	int getPriority() {
		return priority;
	}
	public void setPriority( int priority ) {
		this.priority = priority;
	}
	Units getEstimatedUnits() {
		return estimatedUnits;
	}

	public void setEstimatedUnits( Units estimatedUnits) {
		this.estimatedUnits = estimatedUnits;
	}
	boolean isDone() {
		return isDone;
	}
	public void setDone( boolean isDone) {
		this.isDone = isDone;
	}
	boolean skip() {
		return skip;
	}
	public void setSkip( boolean skip) {
		this.skip = skip;
	}
	List<Task> getChildren() {
		return (children == null ) ? null : new ArrayList<Task>( children );
	}
	
	public void setTasks( List<Task> tasks) {
		this.children = tasks;
	}
	
	boolean hasTasks() {
		return ( children == null ) ? false : true;
	}
	public boolean checkStatus() {
			return id >= 0 && title instanceof String && title.length() > 0;
	}

}
	
